import App from './App'
import { createSSRApp } from 'vue'
// 引入pinia
import { createPinia } from 'pinia'
// 引入pinia持久化插件
// import {piniaPluginPersistedstate} from 'pinia-plugin-persistedstate'
import { createPersistedState } from 'pinia-plugin-persistedstate'

import '@/utils/utils.js'


export function createApp() {
  const app = createSSRApp(App)
  // 创建pinia大仓库
  const pinia = createPinia()

  // 使用pinia
  app.use(pinia)

  // 使用pinia持久化插件
  pinia.use(createPersistedState({
    key: id => `__persisted__${id}`,
    storage :{
      getItem:(key)=>{
       return uni.getStorageSync(key)
      },
      setItem:(key,value)=>{
        uni.setStorageSync(key,value)
      }
    }
  }))

  return {
    app,
  }
}

